package com.mz.ozy.activity.me;

import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.multilevel.treelist.Node;
import com.mz.ozy.R;
import com.mz.ozy.adapter.MyInviteAdapter;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.InviteBean;
import com.mz.ozy.mvp.presenter.MyInvitePresenter;
import com.mz.ozy.mvp.view.MyInviteContract;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MyInviteActivity extends BaseActivity<MyInviteContract.View, MyInvitePresenter> implements MyInviteContract.View {


    protected List<Node> mDatas = new ArrayList<>();
    @BindView(R.id.tv_tz_total)
    TextView tvTzTotal;
    @BindView(R.id.tv_level)
    TextView tvLevel;
    @BindView(R.id.ll_total_view)
    LinearLayout llTotalView;
    @BindView(R.id.tv_zt_num)
    TextView tvZtNum;
    @BindView(R.id.tv_team_num)
    TextView tvTeamNum;
    @BindView(R.id.tv_zt_order)
    TextView tvZtOrder;
    @BindView(R.id.tv_team_order)
    TextView tvTeamOrder;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;
    private MyInviteAdapter mAdapter;
    private int pageNo = 1;
    List<InviteBean.PageItemsBean> mBeanList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_invite);
        ButterKnife.bind(this);
        initTitle2();
        tvCenterTitle.setText(R.string.me_invite);
        initView();
    }

    private void initView() {
        recyclerview.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new MyInviteAdapter(this, mBeanList);
        recyclerview.setAdapter(mAdapter);
        mPresenter.getCommunityLevelList(this, String.valueOf(pageNo));
    }

    @Override
    public void getCommunityLevelListSuccess(InviteBean bean) {

        /*"返回参数说明":"tdgrade(团队级别(0-无 1-5 V1-v5)),ztnum(直推人数),tdnum(团队人数),sum(我的订单总额),ztsum(直推订单总额),tdsum(团队订单总额)," +
                "userlist(直推列表 username(用户名),tdgrade(团队级别(0-无 1-5 V1-v5)),regtime(注册时间),pricesum(订单总额))",*/
        tvTzTotal.setText(bean.getSum());
        tvZtNum.setText(bean.getZtnum()+"");
        tvTeamNum.setText(bean.getTdnum()+"");
        tvZtOrder.setText(bean.getZtsum());
        tvTeamOrder.setText(bean.getTdsum());
        int tdgrade = bean.getTdgrade();
        switch (tdgrade){
            case 0:
                tvLevel.setText("");

                break;
            case 1:
                tvLevel.setText("V1");
                break;
            case 2:
                tvLevel.setText("V2");

                break;
            case 3:
                tvLevel.setText("V3");

                break;
            case 4:
                tvLevel.setText("V4");

                break;
            case 5:
                tvLevel.setText("V5");

                break;
        }
        mBeanList.clear();
        mBeanList.addAll(bean.getUserlist());
        mAdapter.notifyDataSetChanged();


    }


}
